@layout("/common/_container.html"){
<link href="https://pynnn.oss-cn-hangzhou.aliyuncs.com/choice_user.css?v=20200628" rel="stylesheet">
<div style="display: none">
    <input type="hidden" id="payServiceId" value="${payServiceId}">
</div>
<div class="ibox float-e-margins">
    <div>
        <div style="background: #6090b8;color: white;padding: 5px 10px;">会员免费项目设置</div>
        <div id="peopleBox" style="display: flex;flex-flow: wrap;padding-left: 30px;padding-top: 30px;font-size: 16px;">
            @for(str in vipLevelInfoList){
            <div class="divStyle_block" style="width: 85%;margin-bottom:10px;">
                <span class="spanStyle_block">${str.vipLevelName}（${str.num}级）</span>
                <span>
                    <input type="text" class="number" value="0" oninput="value=value.replace(/[^\d]/g,''),decimalNum(this)" style="padding-left: 5px;">
                    <input class="vipLevelId" value="${str.id}" type="hidden">
                </span>
            </div>
            @}
        </div>
        <div class="btnBox">
            <button class="btn" type="button" id="submission">提交</button>
            <button class="btn" type="button" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name))">取消</button>
        </div>
    </div>
</div>
<script>
    $("#submission").click(function () {
        var operativeList = [];
        var payServiceId = $("#payServiceId").val();
        var value = "";
        for (var i = 0; i < $(".divStyle_block").length; i++) {
            value = $(".divStyle_block").eq(i).find('.vipLevelId').val() + "#" + $(".divStyle_block").eq(i).find('.number').val();
            operativeList.push(value)
        }
        $.ajax({
            url: Feng.ctxPath +"/memberPayService/addPayServiceVip",
            type: "post",
            traditional: true,
            data: {
                payServiceId:payServiceId,
                operativeList:operativeList
            },
            success:function (data) {
                Feng.success("操作成功!");
                window.parent.memberPayService.table.refresh();
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            },
            error:function (data) {alert("没有权限，请联系系统管理员！");}
        })
    })
    function decimalNum(obj) {
        obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
        if (obj.value.indexOf(".") < 0 && obj.value != "") {//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
            obj.value = parseFloat(obj.value);
        }
    }
</script>
@}